import Vue from 'vue'
import App from './App.vue'
import router from '@/router'
import TypeNav from '@/components//TypeNav'
import Pagination from '@/components/Pagination/'
import store from '@/store'
import '@/mock/mockServe'
import 'swiper/css/swiper.css'
import Carousel from '@/components/Carousel'
import * as API from '@/api'
import { Button, MessageBox } from 'element-ui'
import VueLazyload from 'vue-lazyload'
import girl from '@/assets/1.jpg'
import VeeValidate from 'vee-validate'
// 中文的提示信息
import zh_CN from 'vee-validate/dist/locale/zh_CN'
Vue.config.productionTip = false
//测试转发请求
// import { reqCategoryList } from '@/api/index.js'
// reqCategoryList()
// 注册全局组件
Vue.component(TypeNav.name, TypeNav)
Vue.component(Carousel.name, Carousel)
Vue.component(Pagination.name, Pagination)
//elementUI组件引入的两种方式
Vue.component(Button.name, Button)
Vue.prototype.$msgbox = MessageBox
Vue.prototype.$alert = MessageBox.alert
Vue.use(VueLazyload, {
  loading: girl,
})

Vue.use(VeeValidate)
VeeValidate.Validator.localize('zh_CN', {
  messages: {
    ...zh_CN.messages,
    is: (field) => `${field}必须与密码相同`, //修改内置规则的message，让确认密码和密码相同
  },
  attributes: {
    phone: '手机号',
    code: '验证码',
    password: '密码',
    password1: '确认密码',
    agree: '协议',
  },
})
VeeValidate.Validator.extend('agree', {
  validate: (value) => {
    return value
  },
  getMessage: (field) => field + '必须同意',
})

new Vue({
  render: (h) => h(App),
  //全局事件总线$bus配置
  beforeCreate() {
    Vue.prototype.$API = API
    Vue.prototype.$bus = this
  },
  //注册路由信息，使得组件身上都拥有$route，$router属性
  router: router,
  //注册仓库
  store,
}).$mount('#app')
